{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Uninstall the Operator and all Feast related objects"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "secret \"postgres-secret\" deleted\n",
      "secret \"feast-data-stores\" deleted\n",
      "featurestore.feast.dev \"sample-db-ssl\" deleted\n",
      "Error from server (NotFound): error when deleting \"../../infra/feast-operator/config/samples/v1alpha1_featurestore_postgres_tls_volumes_ca_env.yaml\": secrets \"postgres-secret\" not found\n",
      "Error from server (NotFound): error when deleting \"../../infra/feast-operator/config/samples/v1alpha1_featurestore_postgres_tls_volumes_ca_env.yaml\": secrets \"feast-data-stores\" not found\n",
      "Error from server (NotFound): error when deleting \"../../infra/feast-operator/config/samples/v1alpha1_featurestore_postgres_tls_volumes_ca_env.yaml\": featurestores.feast.dev \"sample-db-ssl\" not found\n"
     ]
    }
   ],
   "source": [
    "# If you have choosen the option 1 example earlier.\n",
    "!kubectl delete -f ../../infra/feast-operator/config/samples/v1alpha1_featurestore_postgres_db_volumes_tls.yaml\n",
    "\n",
    "# If you have choosen the option 2 example earlier.\n",
    "!kubectl delete -f ../../infra/feast-operator/config/samples/v1alpha1_featurestore_postgres_tls_volumes_ca_env.yaml\n",
    "\n",
    "#!kubectl delete -f ../../infra/feast-operator/dist/install.yaml"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Uninstall the Postgresql using helm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "release \"postgresql\" uninstalled\n",
      "secret \"postgresql-server-certs\" deleted\n",
      "secret \"postgresql-client-certs\" deleted\n",
      "persistentvolumeclaim \"data-postgresql-0\" deleted\n",
      "persistentvolume \"pvc-d0c961d9-7579-4e30-842a-b46812b71f74\" deleted\n"
     ]
    }
   ],
   "source": [
    "# Uninstall the Helm release\n",
    "!helm uninstall postgresql\n",
    "\n",
    "# Delete the secrets\n",
    "!kubectl delete secret postgresql-server-certs\n",
    "!kubectl delete secret postgresql-client-certs\n",
    "\n",
    "# Remove the certificates directory\n",
    "!rm -rf postgres-tls-certs\n",
    "\n",
    "# Remove PV and PVC for clean up. some times those are not deleted automatically and can cause issues.\n",
    "# Delete all PVCs in the default namespace\n",
    "!kubectl delete pvc --all\n",
    "\n",
    "# Delete all PVs\n",
    "!kubectl delete pv --all"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Ensure everything has been removed, or is in the process of being terminated."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "No resources found in feast namespace.\n"
     ]
    }
   ],
   "source": [
    "!kubectl get all"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
